/**
 * Created by JiaJia on 2019/3/27 0027.
 */
public class CountChar {
    public static void main(String[] args) {
        String str="AaBBBBCDEF";
        char ch='b';
        System.out.println(countChar(str,ch));
    }
    
    public static int countChar(String str,char ch){
        int count=0;
        ch=toUpperCase(ch);
        for (int i = 0; i <str.length() ; i++) {
            if(toUpperCase(str.charAt(i))==ch){
                count++;
            }
        }
        return count;
        
    }

    private static char toUpperCase(char ch){
        if(ch>='a'&&ch<='z'){
            return (char)('A'+(ch-'a'));
        }
        return ch;
    }

}